<div class="dataCount mt20 mb20" style="margin-left: 30px;margin-right: 30px;">
    <form  id="searchForm" action="{{url("video/index")}}"  method="post">
        <div class="nav" style="height:85px;">
            <div>
                <input type="text" name="userId"  value="<?php echo $this->request->get('userId'); ?>" placeholder="输入用户ID" class="seek">
                <input type="text" name="nickname" value="<?php echo $this->request->get('nickname'); ?>" placeholder="用户昵称"  class="seek">
                <span class="select-my">
                    <select name="status" data="<?php echo $this->request->get('status') ? $this->request->get('status') : 0; ?>">
                        <option value="0">
                            请选择状态
                        </option>
                        <option value="1">
                            未删除
                        </option>
                        <option value="2">
                            已删除
                        </option>
                    </select>
                </span>
                <button id="search_btn" style="width:80px" type="button">搜索</button>
            </div>
        </div>
    </form>
    <table class="list-tb">
        <tr>
            <th width="3%"><input type="checkbox"  class="ckb_manage"  />全选</th>
            <th width="5%">用户ID</th>
            <th width="5%">用户昵称</th>
            <th width="5%">视频类型</th>
            <th width="5%">祝福语</th>
            <th width="7%">创建时间</th>
            <th width="5%">浏览次数</th>
            <th width="5%">收取红包次数</th>
            <th width="5%">收取金额</th>
            <th width="10%">操作</th>
        </tr>
        {% if list %}
        {% for video in list %}
        <tr>
            <td > <input type="checkbox" name="ids[]"class="ckb" videoId="{{video['id']}}"  value="{{video['id']}}" /></td>
            <td  >{{video['userId']}}</td>
            <td  >
                <p  style="overflow:hidden;text-overflow:ellipsis; -o-text-overflow:ellipsis;white-space:nowrap;width:100%;">  {{video['userName']}} </p>
            </td>
            <td  >
                {% if video['type'] == 0  %}
                讨红包视频
                {% elseif video['type'] == 1 %}
                发红包视频
                {% endif %}
            </td>
            <td  >
                <p  style="overflow:hidden;text-overflow:ellipsis; -o-text-overflow:ellipsis;white-space:nowrap;width:100%;">  {{video['greeting']}} </p>
            </td>
            <td  >{{date('Y-m-d H:i:s',video['createTime'])}}</td>
            <td  >
                {{video['viewCount']}}
            </td>
            <td  >{{video['getPacketCount']}}</td>
            <td  >{{video['getPacketMoney']}}</td>
            <td  >
                {% if video['isDel'] == 0  %}
                <button class="del"   videoId="{{video['id']}}"    type="button">删除</button>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
        {% else  %}
        <tr>
            <td colspan="10">
                <div class="noData">
                    <p class="info">没有符合条件的结果</p>
                </div>
            </td>
        </tr>
        {% endif %}
        <input type="hidden" value="{{url("video/ajaxDel")}}" id="delUrl" />
    </table>
    <div class="page mt30">
        {{ show }}
    </div>
</div>

<script>
    /*
     * 提交搜索表单
     * 
     */
    var submitSearchForm = function () {
        $("#searchForm").submit();
    };


    /*
     * 删除视频
     * @returns {undefined}
     */
    var ajaxDelVideo = function () {
        var videoId = $(this).attr("videoId");
        $.msgbox({
            height: 120,
            content: {type: 'confirm', content: '是否要删除此视频？'},
            onClose: function (result) {
                if (result) {
                    var url = $("#delUrl").val();
                    var id = videoId;
                    if (id == "") {
                        alert("请选择视频");
                        return false;
                    }
                    var json = {
                        "id": id,
                    };
                    var successFunction = function (data) {
                        if (data.status == 200) {
                            alert("删除视频成功");
                            window.location.reload();
                        } else if (data.status == -1) {
                            alert(data.info);
                        }
                    };
                    var errorFunction = function () {

                    };
                    $.ajax({
                        url: url,
                        data: json,
                        type: "post",
                        error: errorFunction,
                        success: successFunction
                    });
                }
            }
        });//msgbox
    }


    $(window).load(function () {
        $('#search_btn').bind('click', submitSearchForm);
        $('.del').bind('click', ajaxDelVideo);
    });



</script>